import { ObjectId } from "mongodb";
import { ApiCall } from "tsrpc";
import { Global, GNum } from "../../models/Global";
import { ReqGetNum, ResGetNum } from "../../shared/protocols/numApi/PtlGetNum";

export async function ApiGetNum(call: ApiCall<ReqGetNum, ResGetNum>) {
    // TODO

    // Global.collection.call()
    let op = await Global.collection('GNum').findOne({
        GNum
    });
    console.log("查找GNum", op);

    if (op) {
        call.succ({
            GNum: GNum
        });
    } else {
        call.error("没有这个值,准备创建");
    }


    // if (call.req.GNum == "Gnum") {
    //     console.log("看看Gnum", GNum);
    //     call.succ({
    //         GNum: GNum,
    //     });
    // } else {
    //     console.error("没有这个值");
    //     call.error("没有这个值");
    // }

}